#include "../engine/core.h"
#include "./BehaviorTree/BTLinkNode.h"
#include "./BehaviorTree/BehaviorTree.h"
#include "./BehaviorTree/BTBlackBoard.h"
#include "LogMgr.h"


//----------------------------------------------------------------------------------------------------------------------------
CBTLinkNode::CBTLinkNode()
: IBTNode( NULL )
{

}

CBTLinkNode::CBTLinkNode( IBTNode *parent )
: IBTNode( parent )
{

}

CBTLinkNode::~CBTLinkNode()
{

}

IBTNode::_eNodeStatus CBTLinkNode::execute()
{
	mpBehaviorTree->_setCurrentNode( this );

	mCurrentChild = mChilds.begin();
	(*mCurrentChild)->execute();

	if ( mpBehaviorTree->getLogFlag() )
	{
		GAMELOGER->debug( "BehaviorTree,%s %d", mName.c_str(), mId );
	}

	return IBTNode::STATUS_SUCCESS;
}

VOID CBTLinkNode::resetParam()
{
	mpBehaviorTree->_setCurrentNode( this );

	mCurrentChild = mChilds.begin();
	(*mCurrentChild)->resetParam();

	if ( mpBehaviorTree->getLogFlag() )
	{
		GAMELOGER->debug( "Reset BehaviorTree,%s %d", mName.c_str(), mId );
	}

}
